package dcedit.util;

// Import Java SDK Classes
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;

/** DynamicOmniButton class */
public class DynamicOmniButton extends JButton {
    /** Serializable constant */
   public static final long serialVersionUID = 1289514824173L;

   /** Default image field */
   private ImageIcon defaultImage;

   /** Button hover image field */
   private ImageIcon hoverImage;

   /** Mouse-down image field */
   private ImageIcon clickImage;

   /** Button disabled image field */
   private ImageIcon disableImage;

   /** Constructor */
   public DynamicOmniButton(String defaultImg, String hoverImg, String clickImg, String disableImg) {
      this(new File(defaultImg), new File(hoverImg), new File(clickImg), new File(disableImg));
   } // END constructor

   /** Constructor */
   public DynamicOmniButton(File defaultImg, File hoverImg, File clickImg, File disableImg) {
      try {
	     if(null != defaultImg) {
            defaultImage = new ImageIcon(ImageIO.read(defaultImg));
            this.setIcon(defaultImage);
	     } // END if
	     if(null != hoverImg) {
            hoverImage = new ImageIcon(ImageIO.read(hoverImg));
            this.setRolloverIcon(hoverImage);
	     } // END if
	     if(null != clickImg) {
            clickImage = new ImageIcon(ImageIO.read(clickImg));
            this.setPressedIcon(clickImage);
	     } // END if
	     if(null != disableImg) {
            disableImage = new ImageIcon(ImageIO.read(disableImg));
            this.setDisabledIcon(disableImage);
	     } // END if
         this.setMargin(new Insets(0, 0, 0, 0));
      } catch(Exception e) {}
   } // END constructor

   /** Constructor */
   public DynamicOmniButton(InputStream defaultImg, InputStream hoverImg, InputStream clickImg, InputStream disableImg) {
      try {
	     if(null != defaultImg) {
            defaultImage = new ImageIcon(ImageIO.read(defaultImg));
            this.setIcon(defaultImage);
	     } // END if
	     if(null != hoverImg) {
            hoverImage = new ImageIcon(ImageIO.read(hoverImg));
            this.setRolloverIcon(hoverImage);
	     } // END if
	     if(null != clickImg) {
            clickImage = new ImageIcon(ImageIO.read(clickImg));
            this.setPressedIcon(clickImage);
	     } // END if
	     if(null != disableImg) {
            disableImage = new ImageIcon(ImageIO.read(disableImg));
            this.setDisabledIcon(disableImage);
	     } // END if
         this.setMargin(new Insets(0, 0, 0, 0));
      } catch(Exception e) {}
   } // END constructor

   /** Constructor */
   public DynamicOmniButton(ImageInputStream defaultImg, ImageInputStream hoverImg, ImageInputStream clickImg, ImageInputStream disableImg) {
      try {
	     if(null != defaultImg) {
            defaultImage = new ImageIcon(ImageIO.read(defaultImg));
            this.setIcon(defaultImage);
	     } // END if
	     if(null != hoverImg) {
            hoverImage = new ImageIcon(ImageIO.read(hoverImg));
            this.setRolloverIcon(hoverImage);
	     } // END if
	     if(null != clickImg) {
            clickImage = new ImageIcon(ImageIO.read(clickImg));
            this.setPressedIcon(clickImage);
	     } // END if
	     if(null != disableImg) {
            disableImage = new ImageIcon(ImageIO.read(disableImg));
            this.setDisabledIcon(disableImage);
	     } // END if
         this.setMargin(new Insets(0, 0, 0, 0));
      } catch(Exception e) {}
   } // END constructor

   /** Constructor */
   public DynamicOmniButton(URL defaultImg, URL hoverImg, URL clickImg, URL disableImg) {
      try {
	     if(null != defaultImg) {
            defaultImage = new ImageIcon(ImageIO.read(defaultImg));
            this.setIcon(defaultImage);
	     } // END if
	     if(null != hoverImg) {
            hoverImage = new ImageIcon(ImageIO.read(hoverImg));
            this.setRolloverIcon(hoverImage);
	     } // END if
	     if(null != clickImg) {
            clickImage = new ImageIcon(ImageIO.read(clickImg));
            this.setPressedIcon(clickImage);
	     } // END if
	     if(null != disableImg) {
            disableImage = new ImageIcon(ImageIO.read(disableImg));
            this.setDisabledIcon(disableImage);
	     } // END if
         this.setMargin(new Insets(0, 0, 0, 0));
      } catch(Exception e) {}
   } // END constructor
} // END class DynamicOmniButton